import { singleton } from "tsyringe";
import { RobotAppPage } from "../../page";
import { $ } from '../../../utils'
@singleton()
export class LiveKrnBottomDialogFragmentC extends RobotAppPage {
    /**
     * 退出直播间
     */
    title: string = `弹框`
    private isRuning: boolean = false;
    dispose(): void {
        this.out()
    }
    is(packageName: string): boolean {
        return `com.smile.gifmaker` === packageName || `com.kuaishou.nebula` === packageName;
    }
    accept(activityName: string): boolean {
        return `com.kuaishou.live.krn.dialog.container.LiveKrnBottomDialogFragment$c` === activityName;
    }
    in(): boolean {
        if (this.isRuning) return;
        this.isRuning = true;
        log(`LiveKrnBottomDialogFragmentC in`)
        this.exitLive()
        return true;
    }
    out(): boolean {
        if (!this.isRuning) return false;
        this.isRuning = false;
        log(`LiveKrnBottomDialogFragmentC Out`)
        return true;
    }

    private exitLive() {
        const ele = $.getVisibleElementByText(`退出直播间`, 1000);
        if (ele) {
            $.clickButton(ele)
            return;
        };
        sleep(500)
        back()
        sleep(500)
        log(`返回`)
    }
}